<template>
  <div class="digital_index">
    <leftNav @routeChange="routeChange"></leftNav>
    <router-view />
    <!-- <engine :modelInfo="modelInfo" @getProgress="getProgress"></engine> -->
  </div>
</template>

<script setup lang="ts">
import leftNav from "../components/leftNav2.vue";
// import engine from '@/components/engine.vue'
import { getElementIdByParamNamePaging, getElementsByParamsPaging } from "@/http/api_hd"
import { useMain } from "@/store/index";
const useMainStore = useMain(); //pinia


let params = reactive({
  resultCount: 999999,
  skipCount: 0,
  fileName: '厂房',
  dataSetId: "3a175c85-3472-26b6-6787-f897eb7834f6",
  elemBehaviour: 0,
  enableFuzzyQuery: true,
  paramGtoup: '',
  paramName: '所属系统',
  paramValues: [] as any,
})
//按属性搜索构件,并隐藏其他构件
function searchAttribute(params: any, isRow: any) {
  window.BlackHole3D.BIM.setElemsValidState("", [], false);
  getElementIdByParamNamePaging(params).then((res: any) => {
    let elemIdList: any[] = [];
    res.data.items?.forEach((item: any) => {
      elemIdList.push(item);
    });
    // console.log('129', elemIdList);

    // 先隐藏所有id集合
    window.BlackHole3D.BIM.setElemsValidState("", [], false);
    let paramsDataId = ''
    if (isRow) {
      paramsDataId = '3a175c856897705edde305e571780607' // 渗id
    } else {
      paramsDataId = '3a175c85347226b66787f897eb7834f6' // 厂房id
    }
    // 再显示指定id集合
    window.BlackHole3D.BIM.setElemsValidState(paramsDataId, elemIdList, true);
    var locIDList = [
      { "dataSetId": "3a153a0ce5994d7f5adf684c14c5c75f", "elemIdList": elemIdList },
    ];
    var backDepth = 1.0;
    var locType = window.BlackHole3D.RECamDirEm.CAM_DIR_DEFAULT;
    // window.BlackHole3D.Camera.setCamLocateToElem(locIDList, backDepth, locType);
  })
}

const routeChange = (row: any) => {
  console.log('54', row);
  window.BlackHole3D.BIM.setElemsValidState("", [], false);
  params.paramValues = []
  params.fileName = '厂房'
  params.dataSetId = '3a175c85-3472-26b6-6787-f897eb7834f6'
  let isRow = false // 如果false则是厂房dataSetId true则是渗滤液dataSetId
  if (row.name == '焚烧炉总貌') {
    params.paramValues = ['锅炉燃烧系统', '锅炉启动燃烧器系统', '锅炉天然气系统', '沼气入炉系统', '渗滤液回喷系统',
      '主蒸汽系统', '锅炉汽水系统', '乙玦吹灰系统', '炉排渣系统', '一二次风及炉墙冷却系统', '蒸汽吹灰系统', '空气预热系统', '锅炉液压系统',
      '疏水排污系统']
  } else if (row.name == '汽轮机本体系统') {
    params.paramValues = ['抽汽系统', '除氧给水系统', '凝结水系统', '汽机本体疏水系统', '汽机润滑油系统',
      'TSI系统', '减温减压系统', 'EH油系统', '轴封系统', '汽机系统']
  } else if (row.name == '垃圾给料系统') {
    params.paramValues = ['垃圾吊起重机系统']
  } else if (row.parentName == '渗滤液系统'){
    isRow = true
    params.fileName = '渗滤液'
    params.dataSetId = '3a175c85-6897-705e-dde3-05e571780607'
    params.paramValues.push(row.name)
  } else {
    params.paramValues.push(row.name)
  }
  // getProgress()
  searchAttribute(params, isRow);
  setTimeout(() => {
    jd(row)
  }, 200);
  useMainStore.updateRouterName(row.name)
}
const jd = (row: any) => {
  if (row.name == '焚烧炉总貌') {
    params.paramValues = ['锅炉燃烧系统', '锅炉启动燃烧器系统', '锅炉天然气系统', '沼气入炉系统', '渗滤液回喷系统',
      '主蒸汽系统', '锅炉汽水系统', '乙玦吹灰系统', '炉排渣系统', '一二次风及炉墙冷却系统', '蒸汽吹灰系统', '空气预热系统', '锅炉液压系统',
      '疏水排污系统']
    visualAngle([15.278164037069146, -86.16856857547853, 57.37764360406237], [0.444580569119647, -0.1627885791837536, -0.30285931873525324, 0.8271180261025652])
  } else if (row.name == '垃圾给料系统') {
    visualAngle([-5.175637899643796, -68.25169029764581, 57.37764360406237], [0.44458056911964683, -0.16278857918375314, -0.3028593187352525, 0.8271180261025657])
  } else if (row.name == '锅炉燃烧系统') {
    visualAngle([8.476815859264264, -73.84744413374256, 57.377643604062484], [0.44458056911964683, -0.16278857918375314, -0.3028593187352525, 0.8271180261025657])
  } else if (row.name == '锅炉启动燃烧器系统') {
    visualAngle([16.318750749113306, -31.95482260337637, 40.74508510659817], [0.37689270002280834, -0.3805297468055235, -0.5999990621545602, 0.5942643602634183])
  } else if (row.name == '锅炉天然气系统') {
    visualAngle([33.35, -59.54, 32.72], [0.514, -0.168, -0.261, 0.7989])
  } else if (row.name == '渗滤液回喷系统') {
    visualAngle([42.7, -72.4, 15.2], [0.577, 0.016, 0.023, 0.815])
  } else if (row.name == '主蒸汽系统') {
    visualAngle([52.57, -65.41, 45.85], [0.514, -0.1684, -0.2615, 0.7989])
  } else if (row.name == '锅炉汽水系统') {
    visualAngle([29.83865039669064, -66.94869859851696, 57.37764360407201], [0.44458056911964655, -0.16278857918375178, -0.3028593187352507, 0.8271180261025668])
  } else if (row.name == '一二次风及炉墙冷却系统') {
    visualAngle([7.921304623850048, -79.38931348792467, 57.37764360407199], [0.44458056911964655, -0.16278857918375178, -0.3028593187352507, 0.8271180261025668])
  } else if (row.name == '空气预热系统') {
    visualAngle([36.6, -46.6, 33.1], [0.44, -0.15, -0.28, 0.83])
  } else if (row.name == '疏水排污系统') {
    visualAngle([33.9, -50.1, 3.9], [0.44, -0.16, -0.3, 0.83])
  } else if (row.name == '汽轮机本体系统') {
    params.paramValues = ['抽汽系统', '除氧给水系统', '凝结水系统', '汽机本体疏水系统', '汽机润滑油系统',
      'TSI系统', '减温减压系统', 'EH油系统', '轴封系统', '汽机系统']
    visualAngle([75.58318083424246, -18.992425209898684, 15.352065675460828], [0.6206472716368074, 0.005585976266904983, 0.007056534713951011, 0.7840382429427555])
  } else if (row.name == '抽汽系统') {
    visualAngle([64.1, -0.94, 15.52], [0.342, -0.188, -0.444, 0.80])
  } else if (row.name == '除氧给水系统') {
    visualAngle([53.24, 37.33, 13.245], [0.01678, 0.6936, 0.7199, 0.0174])
  } else if (row.name == '汽机本体疏水系统') {
    visualAngle([88.73786529357746,29.198760863749964,15.46523060554323], [0.12653163383395052,0.5157213587244688,0.8229539810306814,0.20191079936559064])
  } else if (row.name == '汽机润滑油系统') {
    visualAngle([66.427, 5.588, 19.81], [0.347, -0.1581, -0.3722, 0.8418])
  } else if (row.name == '减温减压系统') {
    visualAngle([74.81, -3.6, 9.1], [0.589, -0.197, -0.248, 0.744])
  }

  else if (row.name == '消防水系统') {
    visualAngle([153.95, -104.46, 31.14], [0.421, -0.0788, -0.1661, 0.888])
  } else if (row.name == '工业水系统') {
    visualAngle([14.92, -50.07, 43], [0.27, -0.20, -0.56, 0.76])
  } else if (row.name == '循环水系统') {
    visualAngle([46.93, -61.18, 103.26], [0.27, -0.20, -0.56, 0.76])
  } else if (row.name == '空压机房压缩空气系统') {
    visualAngle([-29.63, -75.02, 16.1], [0.4, -0.13, -0.3, 0.86])
  } else if (row.name == '渣坑除尘系统') {
    visualAngle([50.27, -41.11, 55.64], [0.35, -0.15, -0.37, 0.84])
  } else if (row.name == '渣坑除尘系统') {
    visualAngle([50.27, -41.11, 55.64], [0.35, -0.15, -0.37, 0.84])
  } else if (row.name == '半干法脱硫系统') {
    visualAngle([141.05515490154443, -45.67361905844595, 30.03544835878977], [0.5400090687415494, 0.3590687503187533, 0.4214883177225136, 0.6338828253272516])
  } else if (row.name == '石灰浆制备系统') {
    visualAngle([108, -74, 14], [0.58, -0.33, -0.36, 0.64])
  } else if (row.name == 'SNCR系统') {
    visualAngle([112, -63, 2.37], [0.62, -0.17, -0.2, 0.72])
  } else if (row.name == 'SCR系统') {
    visualAngle([96, -61, 12], [0.590234335025612, -0.3145207996242182, -0.34961876870596703, 0.6560996974005853])
  } else if (row.name == '布袋除尘系统') {
    visualAngle([151, 14, 31], [0.25, 0.47, 0.74, 0.39])
  } else if (row.name == '飞灰输送系统') {
    visualAngle([70, -58, 24], [0.48, -0.33, -0.45, 0.66])
  } else if (row.name == '活性炭吸附系统') {
    visualAngle([134, -69, 16], [0.35, -0.15, -0.37, 0.84])
  } else if (row.name == '干法脱酸系统') {
    visualAngle([130, -63, 19], [0.37, -0.20, -0.43, 0.79])
  } else if (row.name == '飞灰固化系统') {
    visualAngle([100, -85, 24], [0.56, -0.03, -0.05, 0.82])
  } else if (row.name == '炉内加药系统') {
    visualAngle([-34, -12, 4.6], [0.45, -0.27, -0.44, 0.72])
  } 
  // else if (row.name == '超滤系统') {
  //   visualAngle([-37, -16, 13], [-0.18, 0.41, 0.81, -0.35])
  // } else if (row.name == '反渗透系统') {
  //   visualAngle([-24, -43, 11], [0.42, -0.17, -0.33, 0.82])
  // }
}
const visualAngle = (camPos: any, camRotate: any) => { // 视角定位
  var camLoc = new window.BlackHole3D.RECamLoc();
  camLoc.camPos = camPos;
  camLoc.camRotate = camRotate;
  var locDelay = 0.5;
  var locTime = 1;
  window.BlackHole3D.Camera.setCamLocateTo(camLoc, locDelay, locTime);
}
</script>

<style lang="scss" scoped></style>